<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>
    <?php if(empty($data['news_id'])):?>
    <form action="{:U('add')}" method="post" class="form-horizontal">
        <?php else:?>
        <form action="{:U('edit')}" method="post" class="form-horizontal">
                        <input type="hidden" name="nid" value="{$data['news_id']}"/>

            <?php endif;?>
            <div class="form-item">
                <label class="item-label">文章标题<span class="check-tips">（必填项）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="news_title" value="{$data['news_title']}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">封面图<span class="check-tips">（必填项）</span></label>
                <div class="controls">
                    <input type="file" id="upload_picture_face">
                    <input type="hidden" name="news_img" id="cover_id_face" value="{$data['news_img']}"/>
                    <div class="upload-img-box">
                        <notempty name="data['news_img']">
                            <div class="upload-pre-item"><img src="{$data['news_img']}"/></div>
                        </notempty>
                    </div>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">所属赛事</label>
                <div class="controls">
                    <volist name="eventList" id="vo">
                        <?php
                           $selectd = "";
                           foreach($newsEvent as $row){
                            if($vo['event_id']==$row['event_id']){
                               $selectd = "checked='checked'";
                              
                               break;
                            }
                           }
                        ?>
                   
                        &nbsp;&nbsp;<input class="ids" type="checkbox" name="event_id[]" value="{$vo.event_id}" <?php echo $selectd; ?>/>&nbsp;{$vo.event_name}
                    </volist>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">文章内容<span class="check-tips">（必填项）</span></label>
                <div class="controls">
                    <label class="input-large "><textarea class="text input-large  kind-editor" name="news_content" >{$data['news_content']}</textarea></label>

                </div>
            </div>
            <div class="form-item">
                <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1); return false;">返 回</button>
            </div>
        </form>
</block>

<block name="script">
        <script charset="utf-8" src="__PUBLIC__/static/kindeditor/kindeditor-min.js"></script>
    <script charset="utf-8" src="__PUBLIC__/static/kindeditor/zh_CN.js"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav("{:U('News/index')}");
    </script>
    <script type="text/javascript">
                KindEditor.ready(function(K) {
            window.editor = K.create('textarea[class="kind-editor"]', {
                //allowFileManager : false
                minWidth:900,
                minHeight:300,
                afterBlur: function(){this.sync();},
            });
        });
        //上传图片
        /* 初始化上传插件 */
        $("#upload_picture_face").uploadify({
            "height": 30,
            "swf": "__STATIC__/uploadify/uploadify.swf",
            "fileObjName": "download",
            "buttonText": "上传图片",
            "uploader": "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
            "width": 120,
            'removeTimeout': 1,
            'fileTypeExts': '*.jpg; *.png; *.gif;',
            "onUploadSuccess": uploadPictureface,
            'onFallback': function () {
                alert('未检测到兼容版本的Flash.');
            }
        });
        function uploadPictureface(file, data) {
            var data = $.parseJSON(data);
            console.log(data);
            var src = '';
            if (data.status) {
                $("#cover_id_face").val(data.path);
                src = data.url || '__ROOT__' + data.path
                $("#cover_id_face").parent().find('.upload-img-box').html(
                        '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                        );
            } else {
                updateAlert(data.info);
                setTimeout(function () {
                    $('#top-alert').find('button').click();
                    $(that).removeClass('disabled').prop('disabled', false);
                }, 1500);
            }
        }
    </script>
</block>
